package com.cookiesoft.game.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.cookiesoft.common.annotation.Log;
import com.cookiesoft.common.core.controller.BaseController;
import com.cookiesoft.common.core.domain.AjaxResult;
import com.cookiesoft.common.enums.BusinessType;
import com.cookiesoft.game.domain.ZhenAccount;
import com.cookiesoft.game.service.IZhenAccountService;
import com.cookiesoft.common.utils.poi.ExcelUtil;
import com.cookiesoft.common.core.page.TableDataInfo;

/**
 * 游戏账号，存储用户的游戏账号信息Controller
 *
 * @author anc
 * @date 2024-11-05
 */
@CrossOrigin
@RestController
@RequestMapping("/game/gametype" )
public class ZhenAccountController extends BaseController {
    @Autowired
    private IZhenAccountService zhenAccountService;

/**
 * 查询游戏账号，存储用户的游戏账号信息列表
 */
@PreAuthorize("@ss.hasPermi('game:gametype:list')" )
@GetMapping("/list" )
    public TableDataInfo list(ZhenAccount zhenAccount) {
        startPage();
        List<ZhenAccount> list = zhenAccountService.selectZhenAccountList(zhenAccount);
        return getDataTable(list);
    }

    /**
     * 导出游戏账号，存储用户的游戏账号信息列表
     */
    @PreAuthorize("@ss.hasPermi('game:gametype:export')" )
    @Log(title = "游戏账号，存储用户的游戏账号信息" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, ZhenAccount zhenAccount) {
        List<ZhenAccount> list = zhenAccountService.selectZhenAccountList(zhenAccount);
        ExcelUtil<ZhenAccount> util = new ExcelUtil<ZhenAccount>(ZhenAccount. class);
        util.exportExcel(response, list, "游戏账号，存储用户的游戏账号信息数据" );
    }

    /**
     * 获取游戏账号，存储用户的游戏账号信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('game:gametype:query')" )
    @GetMapping(value = "/{accountId}" )
    public AjaxResult getInfo(@PathVariable("accountId" ) Long accountId) {
        return success(zhenAccountService.selectZhenAccountByAccountId(accountId));
    }

    /**
     * 新增游戏账号，存储用户的游戏账号信息
     */
    @PreAuthorize("@ss.hasPermi('game:gametype:add')" )
    @Log(title = "游戏账号，存储用户的游戏账号信息" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhenAccount zhenAccount) {
        return toAjax(zhenAccountService.insertZhenAccount(zhenAccount));
    }

    /**
     * 修改游戏账号，存储用户的游戏账号信息
     */
    @PreAuthorize("@ss.hasPermi('game:gametype:edit')" )
    @Log(title = "游戏账号，存储用户的游戏账号信息" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhenAccount zhenAccount) {
        return toAjax(zhenAccountService.updateZhenAccount(zhenAccount));
    }

    /**
     * 删除游戏账号，存储用户的游戏账号信息
     */
    @PreAuthorize("@ss.hasPermi('game:gametype:remove')" )
    @Log(title = "游戏账号，存储用户的游戏账号信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{accountIds}" )
    public AjaxResult remove(@PathVariable Long[] accountIds) {
        return toAjax(zhenAccountService.deleteZhenAccountByAccountIds(accountIds));
    }
}
